﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
public partial class Admagazine_ImgFileUpload : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Files.Count > 0)
        {
            HttpPostedFile file = Request.Files[0];
            string msg = "";
            string error = "";
            if (file.ContentLength == 0)
                error = "文件长度为0";
            else
            {
                string filename=Guid.NewGuid().ToString() + Path.GetExtension(file.FileName);
                file.SaveAs(Server.MapPath(".") + "\\pic\\" + filename );
                msg = "pic/"+filename;
            }
            string result = "{ error:'" + error + "', msg:'" + msg + "'}";
            Response.Write(result);
            Response.End();
        }
    }
}
